package com.zxy.controller;

import com.zxy.model.Category;
import com.zxy.model.CategoryQuery;
import com.zxy.model.LoginInfo;
import com.zxy.model.RegisterInfo;
import com.zxy.service.CategoryService;
import com.zxy.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/category")
//restFul
public class CategoryController {

    @Autowired
    private CategoryService categoryService;
    @GetMapping//http://a.com?a=1&b=2  //http://a.com?id=1&name=张三
    public List<Category> select(CategoryQuery query){
      return  categoryService.select(query);
    }

    @PostMapping//通过 RequestBody 请求体 传过来的json数据 给我们自动转为Category 这个对象
    public int insert(@RequestBody Category category){
        return categoryService.insert(category);
    }

    @PutMapping//通过 RequestBody 请求体 传过来的json数据 给我们自动转为Category 这个对象
    public int update(@RequestBody Category category){

        return categoryService.update(category);
    }

    @DeleteMapping//http://a.com?id=1&name=张三
    public int delete(Integer id){
        return categoryService.delete(id);
    }







}
